home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / 1HTP720 (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  2.4 KB  |  62 lines

  1. package com.sun.java.swing.plaf.basic;
  2.  
  3. import com.sun.java.swing.AbstractAction;
  4. import java.awt.event.ActionEvent;
  5. import java.io.Serializable;
  6.  
  7. class BasicTreeUI$TreeTraverseAction extends AbstractAction implements Serializable {
  8.    // $FF: synthetic field
  9.    BasicTreeUI this$0;
  10.    private int direction;
  11.  
  12.    // $FF: synthetic method
  13.    public BasicTreeUI$TreeTraverseAction(BasicTreeUI this$0, int direction, String name) {
  14.       super(name);
  15.       this.this$0 = this$0;
  16.       this.direction = direction;
  17.    }
  18.  
  19.    public void actionPerformed(ActionEvent e) {
  20.       int rowCount;
  21.       if (this.this$0.tree != null && (rowCount = this.this$0.getRowCount()) > 0) {
  22.          int minSelIndex = this.this$0.tree.getMinSelectionRow();
  23.          int newIndex;
  24.          if (minSelIndex == -1) {
  25.             newIndex = 0;
  26.          } else if (this.direction == 1) {
  27.             if (!this.this$0.isLeaf(minSelIndex) && !this.this$0.isExpanded(minSelIndex)) {
  28.                this.this$0.expandRow(minSelIndex);
  29.                newIndex = -1;
  30.             } else {
  31.                newIndex = Math.min(minSelIndex + 1, rowCount - 1);
  32.             }
  33.          } else if (!this.this$0.isLeaf(minSelIndex) && this.this$0.isExpanded(minSelIndex)) {
  34.             this.this$0.collapseRow(minSelIndex);
  35.             newIndex = -1;
  36.          } else {
  37.             try {
  38.                if (!this.this$0.largeModel) {
  39.                   newIndex = ((VisibleTreeNode)this.this$0.getNode(minSelIndex).getParent()).getRow();
  40.                } else {
  41.                   int[] cIndex = new int[1];
  42.                   LargeTreeModelNode parent = this.this$0.getLargeParentAndChildIndexOfRow(minSelIndex, cIndex);
  43.                   newIndex = parent.getRow();
  44.                }
  45.             } catch (Exception var7) {
  46.                newIndex = -1;
  47.             }
  48.          }
  49.  
  50.          if (newIndex != -1) {
  51.             this.this$0.tree.setSelectionInterval(newIndex, newIndex);
  52.             this.this$0.ensureRowsAreVisible(newIndex, newIndex);
  53.          }
  54.       }
  55.  
  56.    }
  57.  
  58.    public boolean isEnabled() {
  59.       return this.this$0.tree != null && this.this$0.tree.isEnabled();
  60.    }
  61. }
  62.